package com.oil.petro.eshop.dao;

import com.oil.petro.eshop.entity.Person;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository("PersonDAO")
public class PersonDAOImpl implements PersonDAO {

    @Autowired
    private SessionFactory sessionfactory;

    @Override
    public Person get(int id) {
        return (Person) sessionfactory.getCurrentSession().get(Person.class, id);
    }

    @Override
    public void delete(Person person) {
        sessionfactory.getCurrentSession().delete(person);
    }

    @Override
    public Integer save(Person person) {
        return (Integer) sessionfactory.getCurrentSession().save(person);
    
    }

    @Override
    public void update(Person person) {
        sessionfactory.getCurrentSession().update(person);
    }

}
